#pragma once
/*Max of internall commands able to registred*/
#define MAX_INTERNAL_COMMANDS 20


typedef int(*fcall)(int agrc, char* argv[]);

typedef enum {FINE = 0, ERROR = -1, EXTERN = 2} cmdExitStatus;
typedef enum {STORE = 0, NOSTORE = -1} cmdHistory;

 

typedef struct {
  char cmd[20];
  fcall fnc;
  char * help;
  cmdHistory store;
} command , *command_ptr;


extern command CSSH_cmd_table[MAX_INTERNAL_COMMANDS];



/*********************************************************************
 * Registring command by name in internall command list
 * name: name for command
 * fnc: Function poinetr to speciefed command
 * 
 * Return:
 * FINE when registring succesfull
 * ERROR whan the list is full
 ********************************************************************/
int register_command(const char * name, fcall fnc, char * help, cmdHistory hist);



/*********************************************************************
 * run internall command by      
 *
 * the name of command is holded @ firest index of param list
 * the total number of parameters ar in args valable
 *
 * return: the return status of found command OR
 * EXTERN return status whan command not found 
 *
 **********************************************************************/ 
int run_command(char * cmdline);


/*********************************************************************
 * get command by name 
 *
 *********************************************************************/
command * get_command( char * name);



/***********************************************************
 * utility function to registry all implemented commands
 * 
 ***********************************************************/
void init_commands();

/***********************************************************
 * free used memmory for parameters
 **********************************************************/
void  free_args(int argc,char * args[]);



/*internall commands functions */


/********************************************
 * Command to exit shell:                
 * -h show help                             
 ********************************************/
int cmd_exit(int args, char * param[]);

/********************************************
 * Show help about internall command
 * -h show help                             
 ********************************************/
int cmd_help(int args, char * param[]);

